package ro.k.servlets.order;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import ro.k.tags.ComandaManopera;
import ro.k.web.beans.order.ManoperaBaseBean;

/**
 * Servlet implementation class AddCutomMan
 */
@WebServlet("/addCustMan")
public class AddCutomMan extends HttpServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * @see HttpServlet#HttpServlet()
	 */
	public AddCutomMan() {
		super();
		// TODO Auto-generated constructor stub
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {

		HttpSession sess = request.getSession();
		
		String pg = request.getParameter("pagina");
		String valoare = request.getParameter("valoare").toString();
		String denumire = request.getParameter("denumire").toString();

		ComandaManopera tagCmd = (ComandaManopera) sess
				.getAttribute("tagCmdMan");
		long time = System.currentTimeMillis();
		time = time % 10000;
		ManoperaBaseBean mbb = new ManoperaBaseBean(denumire, "m"+time, valoare);
		mbb.setCant(1.0);
		mbb.setTotal(Double.parseDouble(mbb.getValoare()));
		tagCmd.addManopera(mbb);

		response.sendRedirect(request.getContextPath() + "/jsp/" + pg);
	}

}
